package redis

import (
	"fmt"
	"github.com/go-redis/redis/v7"
	"log"
	"technician_srv/config"
)

var Client *redis.Client

func InitRedis() {
	show := config.AppConf.RedisConfig
	addr := fmt.Sprintf("%s:%d", show.Host, show.Port)
	Client = redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	pong, err := Client.Ping().Result()
	if err != nil {
		log.Println("缓存连接失败")
		return
	}
	fmt.Println(pong, err)
	log.Println("缓存连接成功")
}
